package com.akl.ssmspringboot.controller;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class QuartzController {


    /**
     * 每分钟的 1-10秒打印出来
     */
//    @Scheduled(fixedRate = 3000)
    @Scheduled(cron = "1-10 0/1 * * * ?")
    public void printTime(){
        Date time = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("这是个quartz定时任务，当前时间是：" + sdf.format(time));
    }


}
